#define SCREEN_SIZE 1600
#define SCREEN_LCROP 0
#define SCREEN_RCROP 131
#define SCREEN_TCROP 0
#define SCREEN_BCROP 79
#define SCREEN_WIDTH 20
#define SCREEN_HEIGHT 80

#define NUM_LIVES       3
#define NUM_BOMBS      12
#define NUM_BASES       4

#define ALIEN_TYPES 3
#define ALIEN_ROWS 5
#define ALIEN_COLUMNS 11
int ALIEN_ROW_TYPES[] = {0, 0, 1, 1, 2};
#define ALIEN_HSHIFT     3
#define ALIEN_VSHIFT     2
#define ALIEN_HSPACE     9
#define ALIEN_VSPACE     9
int ALIEN_VALUE[] = { 10, 20, 30 };

#define SAUCER_Y 0
#define SAUCER_X_START_LEFT 131
#define SAUCER_X_START_RIGHT -11

#define CANNON_RMAX 115
#define CANNON_LMAX 7
#define CANNON_Y    75

#define BASE_Y 61
int BASE_X[] = {13, 42, 71, 100};

#define SAUCER_VALUE_SZ 15
int SAUCER_VALUE[SAUCER_VALUE_SZ] = {100, 50, 50, 100, 150, 100, 100, 50, 300, 100, 100, 100, 50, 150, 100};

typedef unsigned char SPRITE;

typedef enum {
	  NO
	, YES
} LOGICAL;

typedef enum {
	  QUIT
	, PLAY
	, SELECT
} START;

typedef enum {
	  LIVE
	, DYING
	, DEAD
} STATUS;

typedef enum {
	  LEFT  = -1
	, RIGHT =  1
	, RDOWN =  2
	, LDOWN =  3
} DIRECTION;

typedef struct {
	SPRITE    *sprite;
	int        x;
	DIRECTION  direction;
	STATUS     status;
} SAUCER;

typedef struct {
	int       x;
	int       y;
	STATUS    status;
} ALIEN;

typedef struct {
	SPRITE **sprite;
	int      width;
	int      value;
} ALIEN_TYPE;

typedef struct {
	ALIEN_TYPE  *alien_type;
	ALIEN       *alien;
	int         appearance;
	int         tick;
} ALIEN_ROW;

typedef struct {
	ALIEN_ROW  *alien_row;
	DIRECTION   direction;
	int         speed;
	int         current_row;
} ALIENS;

typedef struct {
	SPRITE *sprite;
	int     x;
	int     y;
} BASE;

typedef struct {
	SPRITE *sprite;
	int     x;
	STATUS  status;
} CANNON;

typedef struct {
	SPRITE *sprite;
	int     x;
	int     y;
	int     count;
	STATUS  status;
} LASER;

typedef struct {
	SPRITE **sprite;
	int      appearance;
	int	 speed;
	int      x;
	int      y;
	STATUS   status;
} BOMB;

typedef struct {
	unsigned char  *canvas;
	unsigned char  *screen;
	SAUCER	       *saucer;
	ALIENS         *aliens;
	BASE           *base;
	CANNON         *cannon;
	LASER          *laser;
	BOMB           *bomb;
	int             lives;
	int             score;
	unsigned long   tick;
} WORLD;

